﻿using B.S.Meeting.Domain;
using B.S.Meeting.ErrorCode;
using B.S.Meeting.WriteAPI.Applications.Commands.Approves;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Meeting.WriteAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApproveController : ControllerBase
    {
        IMediator mediator;
        ILogger<ApproveController> logger;

        public ApproveController(IMediator mediator, ILogger<ApproveController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="approveReservation"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdApprove(int apprroveId,string approveName,string approveOpinion,int approveStatus,int meetingreservationId)
        {
            try
            {
                UpdApproveCommand cmd=new UpdApproveCommand
                {
                    ApproveReservationId= apprroveId,
                    ApproveReservationName= approveName,
                    ApproveReservationOpinion= approveOpinion,
                    ApproveReservationStatus=approveStatus,
                    MeetingReservationId= meetingreservationId
                };
                var result=await mediator.Send(cmd);
                return result;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
